package com.aoyebobi;

import java.awt.*;

/**
 * @Description
 * @Author aoyebobi
 * @Date 2024-09-05
 */

public class CardLayoutDemo {
        Frame frame = new Frame("测试窗口");
        String[] names = {"第一张","第二张","第三张","第四张","第五张"};
        //显示的面板
        Panel panel = new Panel();

        public void init(){
            //卡片布局
            final CardLayout cardLayout = new CardLayout();
            panel.setLayout(cardLayout);
            for (int i = 0;i < names.length; i++){
                //设置面板的名字和组件
                panel.add(names[i],new Button(names[i]));
            }

        }
}
